package com.test.lotterysystem.Controller;

import com.test.lotterysystem.Comment.Utils.MyBeanUtil;
import com.test.lotterysystem.Controller.Param.UserRegisterParam;
import com.test.lotterysystem.Controller.Result.UserRegisterResult;
import com.test.lotterysystem.Service.DTO.UserRegisterDTO;
import com.test.lotterysystem.Service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/register")
    public UserRegisterResult register(@Validated @RequestBody UserRegisterParam userRegisterParam) {
        log.info("userRegisterParam为---------: {}",userRegisterParam);

        UserRegisterDTO register = userService.register(userRegisterParam);
        return MyBeanUtil.transOfUserRegisterResult(register);
    }
}
